<?php
/*include /request 不存在的文件将导致错误，所以写了个这个函数先检查在include_path或指定的path里是否存在文件，再试图include*/
function include_file($file,$special_path="")
{
	$file = trim($file);
	if(file_exists($file))
	{
		DAO_Log::debug("include file from ./$file");
		include_once($file);
		return 0;
	}
	$inc_path =  get_include_path().':'.$special_path;

	DAO_Log::debug("include file path :$inc_path");
	$inc_path_array = explode(":",$inc_path);
	foreach($inc_path_array as $key=>$value)
	{

		$value=trim($value);

		if($value==""||$value=="./"||$value==".")
		{
			continue;
		}

		$value=rtrim($value,"\\");
		$value = rtrim($value,"/");
		$value.="/";

		$check_file = $value.$file;
		DAO_Log::debug("check file $check_file");
		if(file_exists($check_file))
		{
			DAO_Log::debug("found $file in  $value");
			include_once($check_file);
			return 0;
		}
	}
	return -1;
}


?>